<%@ page import="java.sql.*"%>
<%@ include file="dbconn.jsp" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Account transactions</title>
<link href="/tros/menuMain.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width=100% bordercolor="#C6D4E1" bgcolor="#C6D4E1">
<tr><th scope="col"><div align="center"><h1 align="center"><font face="Times New Roman">Tros - Online Banking System </font></h1></div></th></tr>
</table>
<div id="overall" align="center">
<div id="dropdwn" align="center">
<ul>
<li><a href='custHome.jsp?value=<%=session.getAttribute( "currentID" )%>'>Home</a>
</li>
</ul>
<ul>
<li><a href='accountInfo.jsp?value=<%=session.getAttribute( "currentID" )%>'>Account</a>
<ul>
<li><a href='viewBalance.jsp?value=<%=session.getAttribute( "currentID" )%>'>View Balance</a></li>
<li><a href='viewTransaction.jsp?value=<%=session.getAttribute( "currentID" )%>'>View Transactions</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href='transferMain.jsp?value=<%=session.getAttribute( "currentID" )%>'>Transfer</a>
<ul>
<li><a href='depositMain.jsp?value=<%=session.getAttribute( "currentID" )%>'>Deposit</a></li>
<li><a href='withdrawal.jsp?value=<%=session.getAttribute( "currentID" )%>'>Withdraw</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href='creditCard.jsp?value=<%=session.getAttribute( "currentID" )%>'>Credit Card</a>
</li>
</ul>
<ul>
<li><a href='paybills.jsp?value=<%=session.getAttribute( "currentID" )%>'>Pay Bills</a>
</li>
</ul>
<ul>
<li><a href='investMain.jsp?value=<%=session.getAttribute( "currentID" )%>'>Investments</a>
<ul>
<li><a href='viewShareInv.jsp?value=<%=session.getAttribute( "currentID" )%>'>Current Shares</a></li>
<li><a href='viewFdInv.jsp?value=<%=session.getAttribute( "currentID" )%>'>Current Fixed Deposit</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href='updatePer.jsp?value=<%=session.getAttribute( "currentID" )%>'>Update Personal Info</a>
<ul>
<li><a href='changePass.jsp?value=<%=session.getAttribute( "currentID" )%>'>Change Password</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href='logout.jsp'>Log Out</a></li>
</ul>
<br class="flow" />
</div>
</div>
&nbsp;
&nbsp;
<fieldset>
&nbsp;
<legend><b>Transactions</b></legend>
<h3 align=center> View Transactions</h3>
<p align=center>Below is the Detailed Transaction Information of the Account</p>
<table width="1000px" align=center cellpadding=5 cellspacing=0 bgcolor="#D5FFD5" >
<tr><td>&nbsp;<td></tr>
<tr><td align="center"><b> Account Number </b></td>
<td align="center"><b> Account Type </b></td>
<td align="center"><b> Transfer Type </b></td>
<td align="center"><b> Amount </b></td>
<td align="center"><b> Date and Time </b></td>
<tr>
<tr><td>&nbsp;</td></tr>
<%
if(request.getParameter("value").startsWith("sav"))
{
	Statement reqst = connect.createStatement();
	ResultSet result =reqst.executeQuery("SELECT * FROM TRANS WHERE ACC_NO="+request.getParameter("value").substring(3));
	
	
	if(!result.next()){ 
		%>
		<tr><td><div align="center"><p>New Account </p></div></td></tr>
		<tr><td><div align="center"><p>No Transactions Available </p></div></td></tr>
	  <% 
	}
	else{
	    do{
	    	 String AccNo=result.getString("ACC_NO");
		      String AccType=result.getString("ACC_TYPE");   
		      String Time=result.getString("TIME_STAMP"); 
		      String TransType=result.getString("TRANS_TYPE");
		      String Amt=result.getString("AMOUNT");	      
	%>
	<tr><td align="center"><%=AccNo %></td>
	<td align="center"><%=AccType %></td>
	<td align="center"><%=TransType %></td>
	<td align="center"><%=Amt %>$</td>
	<td align="center"><%=Time %></td>
	<tr>
	<tr><td>&nbsp;</td></tr>
	<%
	    } 
	    while(result.next());
	}
	
result.close();
reqst.close();
connect.close();
}
else if(request.getParameter("value").startsWith("chk"))
{

	Statement reqstchk = connect.createStatement();
	ResultSet resultchk =reqstchk.executeQuery("SELECT * FROM TRANS WHERE ACC_NO="+request.getParameter("value").substring(3));

	if(!resultchk.next()){ 
		%>
		<tr><td><div align="center"><p>New Account </p></div></td></tr>
		<tr><td><div align="center"><p>No Transactions Available </p></div></td></tr>
	  <% 
	}
	else{
	    do{

		      String AccNo=resultchk.getString("ACC_NO");
		      String AccType=resultchk.getString("ACC_TYPE");   
		      String Time=resultchk.getString("TIME_STAMP"); 
		      String TransType=resultchk.getString("TRANS_TYPE");
		      String Amt=resultchk.getString("AMOUNT");	 
	%>
	<tr><td align="center"><%=AccNo %></td>
	<td align="center"><%=AccType %></td>
	<td align="center"><%=TransType %></td>
	<td align="center"><%=Amt %>$</td>
	<td align="center"><%=Time %></td>
	<tr>
	<tr><td>&nbsp;</td></tr>
	<%
	    } 
	    while(resultchk.next());
	}

resultchk.close();
reqstchk.close();
connect.close();
}
else
{
	 Statement reqFull = connect.createStatement();
	 ResultSet re =reqFull.executeQuery("SELECT * FROM TRANS WHERE CUSTOMERID="+request.getParameter("value"));	 
	 
	 if(!re.next()){ 
		 %>
			<tr><td><div align="center"><p>New Account </p></div></td></tr>
			<tr><td><div align="center"><p>No Transactions Available </p></div></td></tr>
		  <%
		}
		else{
		    do{
		    	  String AccNo=re.getString("ACC_NO");
			      String AccType=re.getString("ACC_TYPE");   
			      String Time=re.getString("TIME_STAMP"); 
			      String TransType=re.getString("TRANS_TYPE");
			      String Amt=re.getString("AMOUNT");	
		 %>
		<tr><td align="center"><%=AccNo %></td>
		<td align="center"><%=AccType %></td>
		<td align="center"><%=TransType %></td>
		<td align="center"><%=Amt %>$</td>
		<td align="center"><%=Time %></td>
		<tr>
		<tr><td>&nbsp;</td></tr>
		<%
		    } 
		    while(re.next());
		}
	 
	 re.close();
	 reqFull.close();
	 connect.close();
}
%>
<tr><td colspan="6"><div align="center"><a href='accountInfo.jsp?value=<%=session.getAttribute( "currentID" )%>'>Account</a></div></td></tr>
</table>
</fieldset>
</body>
</html>